from flask import Flask, request, jsonify
import json

app = Flask(__name__)


@app.route('/test/hello', methods=['POST'])
def reader_insert():
    data = request.get_data()
    json_dict = json.loads(data)
    new_dic = {
        "msg": "你好%s！" % (json_dict.get('name', ''))
    }
    return jsonify(new_dic)


@app.route('/test/save/<int:id>/', methods=['POST'])
def reader_update(id):
    data = request.get_data()
    json_dict = json.loads(data)

    print(json_dict)

    return jsonify({"code": "ok", "message": "操作成功！"})


if __name__ == '__main__':
    app.config['JSON_AS_ASCII'] = False
    app.run(host='0.0.0.0', port=8888, debug=True)
